<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        * {
            border: 0px;
            padding: 0px;
        }

        .box {
            margin: 100px auto;
            text-align: center;
        }

        .txt {
            border: 1px solid red;
            height: 100%;
        }

        span {
            display: inline-block;
            background: gray;
            height: 20px;
            line-height: 20px;
            color: white;
            font-size: 12px;
            padding-left: 20px;
            text-align: left;
            border: 1px solid #ccc;
            width: 150px;

        }

        .true {
            background: url("images/right.png") no-repeat gray 2px 2px;

        }

        .flase {
            background: url("images/wrong.png") no-repeat red 2px 2px;
        }

    </style>
    <script>
        function $(id) {
            return document.getElementById(id);
        }
        function isRealNum(val){
            // isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除
            if(val === "" || val ==null){
                return false;
            }
            if(!isNaN(val)){
                return true;
            }else{
                return false;
            }
        }
        window.onload = function () {
            $("txt").onblur = function () {

                if (isRealNum(this.value) ) {
                    $("sp").className = "true";
                    $("sp").innerHTML = "输入正确成绩为" + this.value;
                }else {
                    $("sp").className = "flase";
                    $("sp").innerHTML = "请输入数字" ;
                }
            }
        }
    </script>
</head>
<body>
<div class="box">
    语文:<input type="text" value="" id="txt" class="txt"/> <span id="sp">请输入成绩</span>
</div>

</body>
</html>